Page({

  /**
   * 页面的初始数据
   */
  data: {
    date: '2023-09-05',
    popup001: false,
    // 费用类型列表
    feeTypeList: [{
      type: 1001,
      name: '酒店',
    }, {
      type: 1002,
      name: '高铁',
    }, {
      type: 1003,
      name: '机票',
    }, {
      type: 1004,
      name: '汽车',
    }, {
      type: 1005,
      name: '船票',
    }, {
      type: 1006,
      name: '打车',
    }, {
      type: 1007,
      name: '物流快递',
    }, {
      type: 1008,
      name: '货拉拉',
    }, {
      type: 1009,
      name: '商务',
    }, {
      type: 1010,
      name: '标书打印',
    }, {
      type: 1011,
      name: '其他',
    }],
    // 人员列表
    userList: [{
      id: 1001,
      name: '张三',
      phone: '13800138000',
    }, {
      id: 1002,
      name: '李阿四',
      phone: '18820138000',
    }, {
      id: 1003,
      name: '古天乐',
      phone: '13300138000',
    }, {
      id: 1004,
      name: '任达华',
      phone: '13200138000',
    }, {
      id: 1005,
      name: '李小龙',
      phone: '13456138000',
    }, {
      id: 1006,
      name: '周星驰',
      phone: '13550138000',
    }, {
      id: 1007,
      name: '孙红雷',
      phone: '13880138000',
    }, {
      id: 1008,
      name: '李立群',
      phone: '13250138000',
    }, {
      id: 1009,
      name: '孙俪',
      phone: '17800138000',
    }, {
      id: 1010,
      name: '汤唯',
      phone: '16800138000',
    }, {
      id: 1011,
      name: '杨安',
      phone: '15800138000',
    }, {
      id: 1012,
      name: '赵志',
      phone: '15200138000',
    }, {
      id: 1013,
      name: '郑成功',
      phone: '15100138000',
    }, {
      id: 1014,
      name: '段誉',
      phone: '15500138000',
    }, {
      id: 1015,
      name: '蒲新蓝',
      phone: '18700138000',
    }, {
      id: 1016,
      name: '刘丽雅',
      phone: '18300138000',
    }, {
      id: 1017,
      name: '邓文怀',
      phone: '18100138000',
    }, {
      id: 1018,
      name: '孙策',
      phone: '13100138000',
    }, {
      id: 1019,
      name: '杨紫琼',
      phone: '15900138000',
    }, {
      id: 1020,
      name: '钱学森',
      phone: '13900138000',
    }],
    // 任务列表
    taskList: [{
      id: 101,
      type: '医院沟通',
      name: '北京市中日友好医院',
      date: '2023-03-08'
    }, {
      id: 201,
      type: '代理沟通',
      name: '山东菏泽立健大药房',
      date: '2023-03-12'
    }, {
      id: 301,
      type: '医院沟通',
      name: '扬州市人民医院',
      date: '2023-04-15'
    }, {
      id: 401,
      type: '医院沟通',
      name: '四川省成都青阳医院',
      date: '2023-07-15'
    }, {
      id: 501,
      type: '医院沟通',
      name: '昆明协和医院',
      date: '2023-06-15'
    }, {
      id: 601,
      type: '医院沟通',
      name: '大同第一人民医院',
      date: '2023-09-15'
    }, {
      id: 701,
      type: '医院沟通',
      name: '北京市天坛医院',
      date: '2023-12-15'
    }, {
      id: 801,
      type: '医院沟通',
      name: '苏州市附属第一人民医院',
      date: '2023-11-15'
    }, {
      id: 901,
      type: '医院沟通',
      name: '昆山市中医院',
      date: '2023-02-15'
    }, {
      id: 110,
      type: '医院沟通',
      name: '南宁协和人民医院',
      date: '2023-08-15'
    }, {
      id: 210,
      type: '医院沟通',
      name: '四川省第一人民医院',
      date: '2023-05-15'
    }],
    // 费用项列表数据
    feeOptionList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    // 进入页面自动弹出选择费用项弹框
    // this.showPopup001()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

  uuid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
      var r = Math.random() * 16 | 0,
        v = c == 'x' ? r : (r & 0x3 | 0x8);
      return v.toString(16);
    });
  },

  bindDateChange(e) {
    console.log(e)
    this.setData({
      date: e.detail.value
    })
  },

  showPopup001() {
    this.setData({
      popup001: true
    })
  },

  hiddenPopup001() {
    this.setData({
      popup001: false
    })
  },

  checkForms() {

  },

  addFeeOption(e) {
    const vm = this;

    vm.hiddenPopup001();
    let list = vm.data.feeOptionList;
    let uuid = vm.uuid();
    console.log(e)
    list.splice(0, 0, {
      type: parseInt(e.currentTarget.dataset.type),
      uuid: uuid,
    });
    vm.setData({
      'feeOptionList': list
    });
    wx.pageScrollTo({
      scrollTop: 0,
    })
  },

  deleteFeeOption(e) {
    const vm = this;

    let list = vm.data.feeOptionList;
    let uuid = e.detail;
    let index = -1;
    list.forEach((item, i) => {
      if (item.uuid == uuid) {
        index = i;
      }
    })
    if (index >= 0) {
      list.splice(index, 1);
      vm.setData({
        'feeOptionList': list
      });
    }
  },

})